package com.yzk.train.${module}.controller.admin;

import com.yzk.train.common.response.Result;
import com.yzk.train.common.response.PageResp;
import com.yzk.train.${module}.request.${Domain}QueryReq;
import com.yzk.train.${module}.request.${Domain}SaveReq;
import com.yzk.train.${module}.response.${Domain}QueryResp;
import com.yzk.train.${module}.service.${Domain}Service;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/${do_main}")
public class ${Domain}AdminController {

    @Resource
    private ${Domain}Service ${domain}Service;

    @PostMapping("/save")
    public Result<Object> save(@Valid @RequestBody ${Domain}SaveReq req) {
        String message = ${domain}Service.save(req);
        return Result.ok(message);
    }

    @GetMapping("/list")
    public Result<PageResp<${Domain}QueryResp>> queryList(@Valid ${Domain}QueryReq req) {
        PageResp<${Domain}QueryResp> pageResp = ${domain}Service.queryList(req);
        return Result.ok(pageResp);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> delete(@PathVariable Long id) {
        ${domain}Service.delete(id);
        return Result.ok("删除成功");
    }

}
